// PkgATest.cpp : Defines the entry point for the console application.
//




#include "stdafx.h"
#include <fstream>
#include <conio.h>

// Include all of your test classes.
#include "FndErrThrowTestSuite.h"
#include "FndErrReportTestSuite.h"
#include "SendMessageErrorTestSuite.h"

using namespace CO::SpiFoundation::ErrorHandling;

// The main application processes all testsuites that you manually add below.
// All output from the tests is redirected to an NUnit Based XML file.
int main(int argc, char* argv[])
{
	std::string outputfilepath = "";
	bool bXml = false;
	
	try
	{
		if(argc > 1)
		{
			// [0] is always the executable itself.
			outputfilepath = argv[1];
			bXml = true;
		}

		Test::Suite ts;
		ts.add(std::auto_ptr<Test::Suite>(new FndErrThrowTestSuite));
		ts.add(std::auto_ptr<Test::Suite>(new FndErrReportTestSuite(1)));
		ts.add(std::auto_ptr<Test::Suite>(new SendMessageErrorTestSuite()));

		std::ofstream theStream;
		if(outputfilepath.length() > 0)
			theStream.open(outputfilepath.c_str());

		Test::Output* pOutput = NULL;
		
		if(bXml)
			pOutput = new Test::XmlOutput(theStream);
		else 
			pOutput = new Test::TextOutput(Test::TextOutput::Verbose);

		std::auto_ptr<Test::Output> output = std::auto_ptr<Test::Output>(pOutput);
		ts.run(*output, false);  // false = DO NOT continue after assertion failures!!!
		theStream.close();
	}
	catch (...)
	{
		std::cout << "unexpected exception encountered in CPPTestRunner\n";
	}

	if(!bXml)
	{
		std::cout << "Press a key to exit!\n";
		getch();
	}

	return 0;
}


